package com.ice.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @author : Ice-winters
 * @since : 2021-06-21 12:58
 */
public class RabbitmqUtil {

    /**
     * 获取MQ连接信道
     *
     * @return channel
     * @throws Exception Exception
     */
    public static Channel getChannel() throws Exception {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setUsername("admin");
        factory.setPassword("admin");
        factory.setVirtualHost("/");
        factory.setPort(5672);
        factory.setHost("81.70.105.175");
        Connection connection = factory.newConnection("zhc-connection");
        return connection.createChannel();
    }

}
